<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>创建店铺</title>
    <style>
        #introduce {
            height: 150px;
        }

        div {
            position: absolute;
            top: 30%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
        }
        table,tr,th,td{
            border: 1px solid #5fbdcb;
        }
        table{
            border-collapse: collapse;
        }
    </style>
</head>
<body>
<div>
    <form action="${pageContext.request.contextPath}/seller.do" method="post">
        <label for="storeName">
            店铺名：<input type="text" name="storeName" id="storeName" placeholder="请输入店铺名"><br>
        </label>
        <label for="introduce">
            店铺简介：<textarea name="introduce" id="introduce" placeholder="请输入店铺简介"></textarea><br>
        </label>
        <input type="button" id="button" value="提交">
    </form>
    <a href="SellerPage.jsp">返回</a>
</div>
<script src="https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"></script>
<script>
    $(function () {
        $('#button').on("click", function () {
            $.ajax({
                url: "http://localhost:8080/store.do",
                type: "post",
                data: {
                    storeName: $('#storeName').val(),
                    introduce: $('#introduce').val(),
                    method: 'create'
                },
                dataType: "text",
                success: function (data) {
                    if (data === "ok") {
                        alert("创建成功！");
                        window.location.href = 'SellerPage.jsp';
                    }
                    if (data === "exist") {
                        alert("店铺名已存在，请重新命名！");
                    }
                    if (data === "error") {
                        alert("创建失败！")
                    }
                }
            })
        })
    })
</script>
</body>
</html>
